home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cgraphix / cbezier.c < prev    next >
Text File  |  1986-05-28  |  1KB  |  73 lines

  1. /* «RM120»«PL99999»«TS4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76» */
  2. #include    <stdio.h>
  3. #define    EXTERN    extern
  4. #include    <typedef.h>
  5.  
  6.  
  7. void BezierDem()
  8. {
  9.     extern double    random();
  10.  
  11.     double    x,temp;
  12.     int        dx,dy,i,n,m,lines,scale;
  13.     int        X1,Y1,X2,Y2;
  14.     PlotArray    b,a;
  15.  
  16.     DefineWindow(1,0,0,XMaxGlb,YMaxGlb);
  17.     DefineWindow(2,0,0,XMaxGlb,YMaxGlb);
  18.     DefineWorld(1, 0., 0., 1000., 1000.);
  19.  
  20.     DefineHeader(2,"A bezier interpolation");
  21.     SetHeaderOn();
  22.  
  23.     n = 12;
  24.     for (i = 0; i < n; i++) {
  25.         a[2 * i] = i;
  26.         a[2 * i + 1] = random()-0.5;
  27.     }
  28.  
  29.     m = 50;
  30.     bezier(a,n,b,m);
  31.  
  32.     FindWorld(2,a,n,(double)1,(double)1.08);
  33.  
  34.     temp = world[2].y1;
  35.     world[2].y1 = world[2].y2;
  36.     world[2].y2 = temp;
  37.     SelectWindow(2);
  38.     DrawBorder();
  39.  
  40.     dx = -8;
  41.     dy = 7;
  42.     X1 = 3;
  43.     Y1 = 5;
  44.     X2 = 25;
  45.     Y2 = 10;
  46.     lines = 0;
  47.     scale = 0;
  48.     DrawAxis(dx,dy,X1,Y1,X2,Y2,lines,scale,FALSE);
  49.     SetLineStyle(1);
  50.     DrawPolygon(a,0,-n,7,2,0);
  51.  
  52.     SetLineStyle(0);
  53.     DrawAxis(0,0,X1,Y1,X2,Y2,0,0,FALSE);
  54.     DrawPolygon(b,0,-m,0,0,0);
  55.  
  56.     SelectWorld(1);
  57.     SelectWindow(1);
  58.  
  59.     DrawTextW((double)730,(double)400,1,"\0337@2   The data");
  60.     DrawTextW((double)730,(double)500,1,"..  The initial polygon");
  61.     DrawTextW((double)730,(double)600,1,"__  The interpolated values");
  62. }
  63.  
  64.  
  65. main()
  66. {
  67.     InitGraphic();
  68.     BezierDem();
  69.     inkey();
  70.     LeaveGraphic();
  71. }
  72.  
  73.